//
//  O2Model.swift
//  MoYoung
//
//  Created by sylar on 2017/9/8.
//  Copyright © 2017年 sylar. All rights reserved.
//

import Foundation
import SQLite
import HandyJSON
import MYModule

open class SingleBloodOxygenModel: NSObject, MYSQLiteTableiabe, SingleSQLite, HandyJSON {
    
    public var adress: String = ""
    
    public var id: Int64 = 0
    
    public var date: Date = Date().sqlDate()
    
   
    public var o2: Int = 0
    
    
    /// 结束测量时间戳
    public var end: Double = 0
    
    required public override init() {}
    
    @discardableResult
    public func updateData() ->Bool {
        
        if o2 <= 0 || o2 >= 255 {
            return false
        }
        if end <= 0 {
            return false
        }
        
        if id == 0 {
            insert()
            return true
        }
        
        update()
        return true
        
    }
    

}
